﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Security.Permissions;
using System.Windows.Forms;

namespace Fcdbas.Platform.Controls
{
    [ToolboxItem(false)]
    public class DataNavigator : BindingNavigator
    {
        [Browsable(false)]
        public bool AllowNew
        {
            get;
            set;
        }

        [Browsable(false)]
        public bool AllowRemove
        {
            get;
            set;
        }

        protected override void OnRefreshItems()
        {
            base.OnRefreshItems();

            if (this.DeleteItem != null &&
                this.BindingSource != null)
                this.DeleteItem.Enabled = this.BindingSource.Count > 0 && AllowRemove;
            if (this.AddNewItem != null)
                this.AddNewItem.Enabled = AllowNew;
        }
    }
}
